package greedy;

/**
 * Created by lh on 2019/7/23.
 * 题目描述：
 * 判断是否为子序列
 * <p>
 * Example:
 * t = "abc", s = "ahbgdc"
 * Return true.
 */
public class Subsequence {
    public static boolean isSubsequence(String str, String target) {
        int i = 0, j = 0;
        while (i < str.length() && j < target.length()) {
            if (str.charAt(i) == target.charAt(j)) {
                j++;
            }
            i++;
        }
        return j == target.length();
    }
}
